<extend name="Public:common"/>
<block name="css">
    <link rel="stylesheet" href="__STATIC__/layui/css/layui.css"  media="all">
    <style>
      th{text-align:center;}
        h3{font-size:18px; padding:10px;}
    </style>
</block>
<block name="content">
    <div class="page-header"><h1><i class="fa fa-home"></i> 数据统计</h1></div>
     <div class="container-fluid">
         <!--线形图及饼状图-->
         <div class="row" style="width:98%;overflow: hidden;margin:0 auto;">
             <div class=" col-md-6 col-xs-6">
                 <form class="form-horizontal" method="post" action="{:U('welcome')}">
                     <div class="form-group">
                         <label for="toDay" class="col-sm-2 control-label">日期选择:</label>
                         <div class="col-sm-8">
                             <input type="text" name="toDay" value="{$toDay}" class="form-control-" id="toDay" placeholder="请选择日期">
                         </div>
                         <div class="col-sm-2">
                             <input type="submit" class="btn btn-primary" value="查询">
                         </div>
                     </div>
                 </form>
                <div id="pie"></div>
             </div>
             <div class=" col-md-6 col-xs-6">
                 <form class="form-horizontal" method="post" action="{:U('welcome')}">
                     <div class="form-group">
                         <label for="inputEmail3" class="col-sm-2 control-label">按年/月筛选:</label>
                         <div class="col-sm-3">
                             <select name="type" id="type">
                                 <option <if condition="$type eq 1">selected</if> value="1">==按年查看==</option>
                                 <option <if condition="$type eq 2">selected</if>  value="2">==按月查看==</option>
                             </select>

                         </div>
                         <div class="col-sm-3">
                             <select name="year" id="year" style="display:<if condition="$type eq 1">block;<else/>none;</if>" >
                                 <volist name="yearList" id="vo">
                                     <option <if condition="$year eq $vo['y']">selected</if> value="{$vo.y}">{$vo.y}</option>
                                 </volist>
                             </select>
                             <select name="month" id="month" style="display:<if condition="$type eq 2">block;<else/>none;</if>"  >
                                 <option value="1" <if condition="$month eq 1">selected</if> >1月</option>
                                 <option value="2" <if condition="$month eq 2">selected</if>>2月</option>
                                 <option value="3" <if condition="$month eq 3">selected</if>>3月</option>
                                 <option value="4" <if condition="$month eq 4">selected</if>>4月</option>
                                 <option value="5" <if condition="$month eq 5">selected</if>>5月</option>
                                 <option value="6" <if condition="$month eq 6">selected</if>>6月</option>
                                 <option value="7" <if condition="$month eq 7">selected</if>>7月</option>
                                 <option value="8" <if condition="$month eq 8">selected</if>>8月</option>
                                 <option value="9" <if condition="$month eq 9">selected</if>>9月</option>
                                 <option value="10" <if condition="$month eq 10">selected</if>>10月</option>
                                 <option value="11" <if condition="$month eq 11">selected</if>>11月</option>
                                 <option value="12" <if condition="$month eq 12">selected</if>>12月</option>
                             </select>
                         </div>
                         <div class="col-sm-2">
                             <input type="submit" class="btn btn-primary" value="查询">
                         </div>
                     </div>
                 </form>
                <div id="strip">
                </div>
             </div>
         </div>
         <!--线形图及饼状图结束-->

         <!--最新消息-->
         <h3>最新消息</h3>
         <div class="newMess">
             <table class="table table-striped table-bordered table-hover table-condensed text-center">
                 <tbody>
                 <tr>
                     <th>序号</th>
                     <th>线路名称</th>
                     <th>线路编号</th>
                     <th>给运营商结算单价</th>
                     <th>发布人</th>
                     <th>运营商名称</th>
                     <th>合作状态</th>
                     <th>建立合作时间</th>
                 </tr>
                <volist name="messList" id="vo">
                 <tr>
                     <td>{$i}</td>
                     <td>{$vo.line_name}</td>
                     <td>{$vo.line_sn}</td>
                     <td>成人{$vo.adult_money};儿童{$vo.child_money};</td>
                     <td>{$vo.supplier_name}</td>
                     <td>{$vo.operator_name}</td>
                     <td>
                        <switch name="vo.partner_status">
                            <case value="0"><label class="label label-primary">申请合作中 </label></case>
                            <case value="1"><label class="label label-success">合作中</label></case>
                            <case value="-1"><label class="label label-danger">运营商拒绝合作</label></case>
                            <case value="-2"><label class="label label-danger">供应商中止合作</label></case>
                        </switch>
                     </td>
                     <td>{$vo.partner_time|date="Y-m-d",###}</td>
                 </tr>
                </volist>
                 </tbody>
             </table>
         </div>
         <!--最新消息结束-->
         <!--最新订单-->
         <h3>最新订单</h3>
         <div class="newMess">
             <table class="table table-striped table-bordered table-hover table-condensed text-center">
                 <tbody>
                 <tr >
                     <th>序号</th>
                     <th>线路名称</th>
                     <th>线路编号</th>
                     <th>团号</th>
                     <!--<th>结算总额</th>-->
                     <th>下单时间</th>
                     <th>出团时间</th>
                    <!-- <th>余位</th>-->
                     <th>预计收客</th>
                     <th>状态</th>
                     <th>操作</th>
                 </tr>
                 <volist name="orderList" id="vo">
                     <tr>
                         <td>{$i}</td>
                         <td>{$vo.line_name}</td>
                         <td>{$vo.line_sn}</td>
                         <td>{$vo.group_num}</td>
                         <!--<td>{$vo.operator_cost}</td>-->
                         <td>{$vo.create_time|date="Y-m-d H:i:s",###}</td>
                         <td>{$vo.out_time|date="Y-m-d",###}</td>
                         <!--<td>4</td>-->
                         <td>{$vo.expect_num}</td>
                         <td>
                             <switch name="vo.group_status">
                                <case value="0">待处理</case>
                                <case value="2">已出团</case>
                                <case value="1">已成团</case>
                                <case value="-1">不成团</case>
                                <case value="3">已回团</case>
                             </switch>
                         </td>
                         <td>
                             <if condition="checkAuth('Dealer/Product/groupManage')">
                                 <a href="{:U('Product/groupManage')}" class="btn btn-xs btn-primary">详情</a>
                             </if>
                             <if condition="checkAuth('Dealer/Finance/financeList')">
                                <a href="{:U('Finance/financeList')}" class="btn btn-xs btn-primary">结算</a>
                             </if>
                         </td>
                     </tr>
                 </volist>
                 </tbody>
             </table>
         </div>
         <!--最新订单结束-->

         <!--产品审核-->
         <h3>产品审核</h3>
         <div class="newMess">
             <table class="table table-striped table-bordered table-hover table-condensed text-center">
                 <tbody>
                 <tr >
                     <th>供应商名称</th>
                     <th>产品名称</th>
                     <th>供应商编号</th>
                     <th>销售单价</th>
                     <th>合作时间</th>
                     <th>操作人</th>
                     <th>审核状态</th>
                     <th>是否上架</th>
                     <th>操作</th>
                 </tr>
                 <!--酒店-->
                <volist name="auditList['hotelList']" id="vo">
                     <tr>
                         <td>{$vo.supplier_name}</td>
                         <td>酒店</td>
                         <td>{$vo.supplier_sn}</td>
                         <td>{$vo.room_name}: 儿童价：{$vo.child_actual_cost}元/人<br>成人价：{$vo.adult_actual_cost}元/人 </td>
                         <td>{$vo.start_time|date="Y-m-d",###}至{$vo.end_time|date="Y-m-d",###}</td>
                         <td>{$vo.audit_name}</td>
                         <td>
                             <switch name="vo.is_review">
                                 <case value="1">已审核</case>
                                 <case value="-1">未审核</case>
                                 <case value="-2">已拒绝</case>
                             </switch>
                         </td>
                         <td>
                             <switch name="vo.is_shelves">
                                 <case value="1">是</case>
                                 <case value="-1">否</case>
                             </switch>
                         </td>
                         <td>
                             <if condition="checkAuth('Dealer/Shops/hotelProductById')">
                                 <a href="{:U('Shops/hotelProductById',array('id'=>$vo['supplier_id']))}" class="btn btn-xs btn-primary">详情</a>
                             </if>
                         </td>
                     </tr>
                </volist>
                 <!--景区-->

                 <volist name="auditList['scenicList']" id="vo">
                     <tr>
                         <td>{$vo.supplier_name}</td>
                         <td>景区</td>
                         <td>{$vo.supplier_sn}</td>
                         <td>{$vo.scenic_name}: 儿童价：{$vo.child_actual_cost}元/人<br>成人价：{$vo.adult_actual_cost}元/人 </td>
                         <td>{$vo.start_time|date="Y-m-d",###}至{$vo.end_time|date="Y-m-d",###}</td>
                         <td>{$vo.audit_name}</td>
                         <td>
                             <switch name="vo.is_review">
                                 <case value="1">已审核</case>
                                 <case value="-1">未审核</case>
                                 <case value="-2">已拒绝</case>
                             </switch>
                         </td>
                         <td>
                             <switch name="vo.is_shelves">
                                 <case value="1">是</case>
                                 <case value="-1">否</case>
                             </switch>
                         </td>
                         <td>
                             <if condition="checkAuth('Dealer/Shops/scenicProductById')">
                                 <a href="{:U('Shops/scenicProductById',array('id'=>$vo['supplier_id']))}" class="btn btn-xs btn-primary">详情</a>
                             </if>

                         </td>
                     </tr>
                 </volist>
                 <!--保险-->
                 <volist name="auditList['insureList']" id="vo">
                     <tr>
                         <td>{$vo.supplier_name}</td>
                         <td>保险</td>
                         <td>{$vo.supplier_sn}</td>
                         <td>{$vo.insure_name}: 儿童价：{$vo.child_actual_cost}元/人<br>成人价：{$vo.adult_actual_cost}元/人 </td>
                         <td>{$vo.start_time|date="Y-m-d",###}至{$vo.end_time|date="Y-m-d",###}</td>
                         <td>{$vo.audit_name}</td>
                         <td>
                             <switch name="vo.is_review">
                                 <case value="1">已审核</case>
                                 <case value="-1">未审核</case>
                                 <case value="-2">已拒绝</case>
                             </switch>
                         </td>
                         <td>
                             <switch name="vo.is_shelves">
                                 <case value="1">是</case>
                                 <case value="-1">否</case>
                             </switch>
                         </td>
                         <td>
                             <if condition="checkAuth('Dealer/Shops/insureProductById')">
                                 <a href="{:U('Shops/insureProductById',array('id'=>$vo['supplier_id']))}" class="btn btn-xs btn-primary">详情</a>
                             </if>
                         </td>
                     </tr>
                 </volist>

                 <!--交通-->
                 <volist name="auditList['trafficList']" id="vo">
                     <tr>
                         <td>{$vo.supplier_name}</td>
                         <td>交通</td>
                         <td>{$vo.supplier_sn}</td>
                         <td>{$vo.traffic_name}: 儿童价：{$vo.child_actual_cost}元/人<br>成人价：{$vo.adult_actual_cost}元/人 </td>
                         <td>{$vo.start_time|date="Y-m-d",###}至{$vo.end_time|date="Y-m-d",###}</td>
                         <td>{$vo.audit_name}</td>
                         <td>
                             <switch name="vo.is_review">
                                 <case value="1">已审核</case>
                                 <case value="-1">未审核</case>
                                 <case value="-2">已拒绝</case>
                             </switch>
                         </td>
                         <td>
                             <switch name="vo.is_shelves">
                                 <case value="1">是</case>
                                 <case value="-1">否</case>
                             </switch>
                         </td>
                         <td>
                             <if condition="checkAuth('Dealer/Shops/trafficProductById')">
                                 <a href="{:U('Shops/trafficProductById',array('id'=>$vo['supplier_id']))}" class="btn btn-xs btn-primary">详情</a>
                             </if>
                         </td>
                     </tr>
                 </volist>
                 </tbody>
             </table>
         </div>
         <!--产品审核结束-->
     </div>
</block>
<block name="js">
    <script src="__STATIC__/Dealer/js/highcharts.js"></script>
    <script src="__STATIC__/Dealer/js/highcharts-zh_CN.js"></script>
    <script src="__STATIC__/Dealer/js/exporting.js"></script>

    <script src="__STATIC__/layui/layui.all.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>

    <script>

        layui.use('laydate', function() {
            var laydate = layui.laydate;
            //常规用法
            laydate.render({
                elem: '#toDay'
            });
            laydate.render({
                elem: '#end_time'
            });
        })


        $(function () {
            $('body').on('change','#type',function () {
               var selected=$(this).val();
               if(selected==1){
                   $('#year').show();
                   $('#month').hide();
               }else{
                   $('#year').hide();
                   $('#month').show();
               }
            });


            //饼状图
            $('#pie').highcharts({
                chart: {
                    plotBackgroundColor: null,
                    plotBorderWidth: null,
                    plotShadow: false
                },
                title: {
                    text: '{$toDay}营业额 {$turnover.total}'
                },
                tooltip: {
                    headerFormat: '{series.name}<br>',
                    pointFormat: '{point.name}: <b>{point.percentage:.1f}%</b>'
                },
                plotOptions: {
                    pie: {
                        allowPointSelect: true,
                        cursor: 'pointer',
                        dataLabels: {
                            enabled: true,
                            format: '<b>{point.name}</b>: {point.percentage:.1f} %',
                            style: {
                                color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                            }
                        }
                    }
                },
                series: [{
                    type: 'pie',
                    name: '营业额利润比例',
                    data: [
                        ['毛利:{$turnover.profit|default=0}元',   {$turnover.profitPercent|default=100}],
                        ['成本:{$turnover.cost|default=0}元',       {$turnover.totalPercent|default=0}],
                    ]
                }]
            });

            //条形图

            /**
             * Highcharts 在 4.2.0 开始已经不依赖 jQuery 了，直接用其构造函数既可创建图表
             **/
            var chart = new Highcharts.Chart('strip', {
                title: {
                    text: '营业收入报表',
                    x: -20
                },
               /* subtitle: {
                    text: '数据来源: WorldClimate.com',
                    x: -20
                },*/
                xAxis: {
                    categories: [<volist name="report" id="vo">"{$vo.name}",</volist>]
                },
                yAxis: {
                    title: {
                        text: '金额'
                    },
                    plotLines: [{
                        value: 0,
                        width: 1,
                        color: '#808080'
                    }]
                },
                tooltip: {
                    valueSuffix: ''
                    //valueSuffix: '元'
                },
                legend: {
                    layout: 'vertical',
                    align: 'right',
                    verticalAlign: 'middle',
                    borderWidth: 0
                },
                series: [{
                    name: '订单数量',
                    data: [<volist name="report" id="vo">{$vo.orderNum},</volist>]
                }, {
                    name: '毛利',
                    data: [<volist name="report" id="vo">{$vo.profit},</volist>]
                }, {
                    name: '营业额',
                    data: [<volist name="report" id="vo">{$vo.turnover},</volist>]
                }]
            });

        });

    </script>
</block>